import { createRouter, createWebHashHistory } from 'vue-router';

const Layout = () => import('../layout/Index');

const Dashboard = () => import('../views/dashboard/Dashboard');

const UserInfo = () => import('../views/user/UserInfo');
const ResetPassword = () => import('../views/user/ResetPassword');

const ArticleCategory = () => import('../views/blog/ArticleCategory');
const ArticleList = () => import('../views/blog/ArticleList');
const ArticleEdit = () => import('../views/blog/ArticleEdit');

const routes = [
  {
    path: '/user',
    component: Layout,
    children: [
      {
        path: 'info',
        name: 'user-info',
        component: UserInfo
      },
      {
        path: 'password',
        name: 'reset-password',
        component: ResetPassword
      }
    ]
  },
  {
    path: '/blog',
    component: Layout,
    children: [
      {
        path: 'category',
        name: 'article-category',
        component: ArticleCategory
      },
      {
        path: 'list',
        name: 'article-list',
        component: ArticleList
      },
      {
        path: 'edit',
        name: 'article-edit',
        component: ArticleEdit
      }
    ]
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'dashboard',
        component: Dashboard
      }
    ]
  }
];

const router = createRouter({
  history: createWebHashHistory(),
  routes
});

export default router;
